package com.yl.paymanagement.config;


import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;

import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    @Bean
    public TopicExchange exchangetopic(){
        return new TopicExchange("exchangeTopicSendEmail");
    }

    @Bean
    public Queue queuesms(){
        return new Queue("queueSendEmail");
    }
    @Bean
    public Binding bindingEmail(){
        return BindingBuilder.bind(queuesms()).to(exchangetopic()).with("#.email.#");
    }

    @Bean
    public MessageConverter messageConverter(){
        Jackson2JsonMessageConverter jackson2JsonMessageConverter = new Jackson2JsonMessageConverter();
        jackson2JsonMessageConverter.setAlwaysConvertToInferredType(true);
        return jackson2JsonMessageConverter ;
    }
}
